home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Plus / Multimedia Plus with ClearVue Version 10-94 (Knowledge Media Inc.).ISO / dos / anim / flilib / flisrc / clock.asm < prev    next >
Assembly Source File  |  1989-12-17  |  1KB  |  52 lines

  1. ;clock.asm - contains aa_goclock(), aa_getclock.
  2.  
  3. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  4.  
  5.     ASSUME  CS: _TEXT 
  6.  
  7.  
  8.  
  9. CMODE    equ    043h
  10. CDATA    equ 040h
  11.  
  12.     public _aa_goclock
  13. ;Set up clock registers for aa_getclock.  Should be called before aa_getclock.
  14. _aa_goclock proc far
  15.     mov al,00110100b    ;put it into linear count instead of divide by 2
  16.     out CMODE,al
  17.     xor al,al
  18.     out CDATA,al
  19.     out CDATA,al
  20.     ret
  21. _aa_goclock endp
  22.  
  23.     public _aa_getclock
  24. ;this routine returns a clock with occassional spikes where time
  25. ;will look like its running backwards 1/18th of a second.  The resolution
  26. ;of the clock is 1/(18*256) = 1/4608 second.  66 ticks of this clock
  27. ;are supposed to be equal to a monitor 1/70 second tick.
  28.  
  29. _aa_getclock proc far
  30.     push cx
  31.  
  32.     mov ah,0    ;get tick count from dos and use for hi 3 bytes
  33.     int 01ah    ;lo order count in dx, hi order in cx
  34.     mov ah,dl    
  35.     mov dl,dh
  36.     mov dh,cl
  37.  
  38.     mov al,0        ;read lo byte straight from timer chip
  39.     out CMODE,al    ;latch count
  40.     mov al,1
  41.     out CMODE,al    ;set up to read count
  42.     in al,CDATA    ;read in lo byte (and discard)
  43.     in al,CDATA    ;hi byte into al
  44.     neg al        ;make it so counting up instead of down
  45.  
  46.     pop cx
  47.     ret
  48. _aa_getclock endp
  49.  
  50. _TEXT    ENDS
  51. END
  52.